package com.winchain.chainbill.serfee.rx;

import com.shell.bee.base.utils.MoneyUtil;
import com.shell.framework.rx.OnErrorNotImplementedSubscriber;
import com.shell.framework.utils.CommonDataUtil;
import com.shell.framework.utils.MessageSender;
import com.shell.governor.modules.message.keyword.SmsTBillDctPaySerFeePassKeyword;
import com.winchain.chainbill.bill.base.po.CbDct;
import com.winchain.chainbill.bill.base.po.CbRec;
import com.winchain.chainbill.bill.biz.Bill;
import com.winchain.chainbill.bill.biz.BillEvent;
import org.springframework.stereotype.Component;

@Component
public class BillReAprvMsgSubscriber extends OnErrorNotImplementedSubscriber<BillEvent<CbDct>> {
	public void onApplicationEvent(BillEvent<CbDct> t) {
		CbDct dct = (CbDct) t.getBill().getSource();
		CbRec rec = t.getBill().getRec();
		String template = "MT09006";
		SmsTBillDctPaySerFeePassKeyword keyword = new SmsTBillDctPaySerFeePassKeyword();
		keyword.setBillCode(rec.getBillCode());
		keyword.setCusName(dct.getSellerNm());
		keyword.setDctAmt(MoneyUtil.format(dct.getDctAmt()));
		String senderId = CommonDataUtil.getUserId();
		MessageSender.sendMessageByTmpl(senderId, template, keyword, dct.getFinId());
	}
}
